package com.e3.basdoc.corp.client;

import java.util.List;

import com.e3.basdoc.corp.model.CorpModel;
import com.e3.template.tgf.MyTGFUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFStateMachine;
import com.e3.template.tgf.TGFTabFormPanel;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.e3.web.core.client.GXTHelper;
import com.e3.web.widget.client.BaseAction;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Description: <br>
 * 
 * @author: <a href="mailto:senton1101@126.com">TianXiangdong</a> 2010-7-27 上午10:41:03
 * @version: 1.0
 */
public class CorpUI extends MyTGFUI<CorpModel> {
	
	private CorpRPCServiceAsync service = CorpRPCService.Util.getInstance();

	@Override
	protected TGFTabFormPanel<CorpModel> createFormPanel() {
		return new CorpFormPanel();
	}

	@Override
	protected TGFGridPanel<CorpModel> createGridPanel() {
		return new CorpGridPanel();
	}

	@Override
	protected TGFTreePanelAsync<CorpModel> createTreePanel() {
		return new CorpTreePanel();
	}

	@Override
	protected TGFQueryDialog<CorpModel> createQueryDialog() {
		return new CorpQueryDialog();
	}

	@Override
	protected TGFEditorDialog<CorpModel> createEditorDialog() {
		return new CorpEditorDialog();
	}

	@Override
	protected void executeDeleteService(List<CorpModel> models,	AsyncCallback<Void> callback) {
		service.deleteCorps(models, callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return CorpMessages.INSTANCE.local_name();
	}

	@Override
	protected CorpModel createModelInstance() {
		return CorpHelper.INSTANCE.createModelInstance();
	}
	
	@Override
	protected BaseAction[] getTreeGridContextMenuActions() {
		if(GXTHelper.isSuperAdmin()||GXTHelper.isLocalCorp()){
			return super.getTreeGridContextMenuActions();	
		}
		return new BaseAction[]{TGFStateMachine.MODIFY_ACTION};
	}

	@Override
	protected BaseAction[] getToolButtonActions() {
		if(GXTHelper.isSuperAdmin()||GXTHelper.isLocalCorp()){
			return super.getToolButtonActions();
		}
		return new BaseAction[]{TGFStateMachine.MODIFY_ACTION};
	}
}
